<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition 
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets">
    
    <style type="text/css">
  		@import url("stylesheet.css");
	</style>

<ui:insert name="contentFields">
	<h:outputLabel class="rub1" value="Kundkorg"></h:outputLabel>
	<br/> <br/>
	</ui:insert>

<ui:insert name="checkoutFields">
	<f:view>
		<h:panelGroup id="loginForm" rendered="#{!loginBean.loggedin}">
			<h:form>
			<h:outputLabel value="Du måste vara inloggad för att kunna lägga en beställning"></h:outputLabel>
			<br/>
			<br/>
			<h:commandLink action="${navigatorBean.setPage('login')}" value="Klicka här för att logga in" styleClass="link">
				<f:ajax render="mainContent"/>
			</h:commandLink>
			</h:form>
		</h:panelGroup>
		
		<br/><br/>
		<h:panelGroup id="shoppingBasket" rendered="#{loginBean.loggedin}">
			<h:panelGrid>
				<h:outputLabel value="Du är inloggad, varsågod att skicka din beställning."></h:outputLabel>
				<h:dataTable value="${shoppingBean.getShoppingBasketAsArrayList()}" var="product">
    				<h:column>
    					<f:facet name="header"><h:outputText value="Vara:" /></f:facet>
       			 		<h:link value="#{product.name}    " outcome="product"/>
    				</h:column>
    				<h:column>
    					<f:facet name="header"><h:outputText value="Pris:" /></f:facet>
       			 		<h:link value="#{product.price}kr/st" outcome="product"/>
    				</h:column>
    				<h:column>
    					<f:facet name="header"><h:outputText value="Antal:" /></f:facet>
       			 		<h:link value="1st" outcome="product"/>
    				</h:column>
				</h:dataTable>
			<h:outputLabel  value=" = Totalt: #{shoppingBean.getShoppingBasketTotal()}"/>
			
			<h:form>
				<h:commandButton action="${shoppingBean.checkOut(loginBean.username)}" value="Klicka för att skicka!">
					<f:ajax render="mainContent"/>
				</h:commandButton>
			</h:form>
			
			</h:panelGrid>
		</h:panelGroup>
		
	</f:view>
</ui:insert>

</ui:composition>